package com.his.mapper;

import com.his.controller.form.ScheduleByDayForm;
import com.his.controller.info.UserByDayInfo;
import com.his.model.Schedule;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 梅津铧
 * @since 2022-03-22
 */
public interface ScheduleMapper extends BaseMapper<Schedule> {

    /**
     * 批量添加排班信息
     * @param schedules 排班信息
     */
    Integer increaseSchedules(@Param("list")List<Schedule> schedules);

    @Select("SELECT ts.schedule_user_id,ts.schedule_user_name FROM tb_schedule ts\n" +
            "JOIN tb_user_info tui\n" +
            "ON ts.schedule_user_id=tui.user_job_num\n" +
            "WHERE tui.user_role_name=#{rolename} And ts.department_id=#{departmentid} AND ts.disagnosis_id=#{disagnosisid} AND ts.work_time=#{worktime} AND ts.schedule_state=1")
    List<UserByDayInfo> obtainByDayInfo(@Param("rolename") String rolename,@Param("departmentid") Integer departmentid,@Param("disagnosisid") Integer disagnosisid,@Param("worktime") String worktime);

    @Select("SELECT ts.schedule_user_id,ts.schedule_user_name FROM tb_schedule ts\n" +
            "JOIN tb_user_info tui\n" +
            "ON ts.schedule_user_id=tui.user_job_num\n" +
            "WHERE tui.user_role_name=#{rolename} And ts.department_id=#{departmentid} AND ts.work_time=#{worktime} AND ts.schedule_state=1")
    List<UserByDayInfo> obtainByDayNoDis(@Param("rolename") String rolename,@Param("departmentid") Integer departmentid,@Param("worktime") String worktime);

}
